home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / strlib.zip / STRPREF.C < prev    next >
Text File  |  1993-01-04  |  896b  |  27 lines

  1.  
  2. /*  File   : strpref.c
  3.     Author : Richard A. O'Keefe.
  4.     Updated: 11 April 1984
  5.     Defines: strpref()
  6.  
  7.     strpref(src, prefix)
  8.     checks whether prefix is a prefix of src.  If it is not, the  result
  9.     is  NullS.  If it is, the result is a pointer to the first character
  10.     of src after the prefix (src+strlen(prefix)).  You can use this in a
  11.     conditional as a test: if (strpref(....)), but this is only portable
  12.     provided you remember to declare strpref() properly or use strings.h
  13.     as if (...) tests numbers against 0 and pointers against a suitable
  14.     cast of 0; there is no guarantee that (char*)0 is represented by the
  15.     same bit pattern as (int)0.
  16. */
  17.  
  18. #include "strings.h"
  19.  
  20. char *strpref(src, prefix)
  21.     register char *src, *prefix;
  22.     {
  23.         while (*prefix) if (*src++ != *prefix++) return NullS;
  24.         return src;
  25.     }
  26.  
  27.